from django.contrib.auth.models import Permission,ContentType
from rest_framework.permissions import IsAdminUser
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet

from meiduo_admin.serializers.permissions import PermissionSerializer, ContentTypeSerializer
from meiduo_admin.serializers.user import PageNum


class PermissionView(ModelViewSet):
    queryset = Permission.objects.all()
    serializer_class = PermissionSerializer
    pagination_class = PageNum
    permission_classes = [IsAdminUser]

    def content_type(self,request):
        data = ContentType.objects.all()
        ser =ContentTypeSerializer(data,many=True)
        return Response(ser.data)

